package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cheer.entity.StandingBookDocument;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface StandingBookDocumentDao extends BaseMapper<StandingBookDocument> {

    default List<StandingBookDocument> listByAccountId(Long accountId) {
        return selectList(new QueryWrapper<StandingBookDocument>()
                .eq("account_id", accountId));
    }

    default void deleteByAccountIds(List<Long> accountIds) {
        delete((new QueryWrapper<StandingBookDocument>()
                .in("account_id", accountIds)));
    }

    default void deleteByAccountIdAndInType(Long accountId, List<Integer> docTypes) {
        delete((new QueryWrapper<StandingBookDocument>()
                .eq("account_id", accountId))
                .in("doc_type", docTypes));
    }

    default void deleteByAccountIdAndBetweenType(Long accountId, Integer minType, Integer maxType) {
        delete((new QueryWrapper<StandingBookDocument>()
                .eq("account_id", accountId))
                .between("doc_type", minType, maxType));
    }

    void insertBatch(List<StandingBookDocument> entityList);


    default StandingBookDocument listByAccountIdAndTypes(Long accountId, Integer docType){

        return selectOne(new QueryWrapper<StandingBookDocument>()
                .eq("account_id", accountId).eq("doc_type", docType));
    }


}
